xen-tmem-list-parse: fix ugly parse output
authorDan Magenheimer <dan.magenheimer@oracle.com>
Wed, 14 Nov 2012 10:24:28 +0000 (10:24 +0000)
committerDan Magenheimer <dan.magenheimer@oracle.com>
Wed, 14 Nov 2012 10:24:28 +0000 (10:24 +0000)
The program xen-tmem-list-parse parses the output of xm/xl tmem-list
into human-readable format.  A missing NULL terminator sometimes
causes garbage to be spewed where the two-letter pool type
should be output.

Signed-off-by: Dan Magenheimer <dan.magenheimer@oracle.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
tools/misc/xen-tmem-list-parse.c

index 977e4d3cc25414a4b8c40680b570d27c105158ed..f32b107dcef48f5b9c45550217e4529595080c27 100644 (file)
@@ -243,6 +243,7 @@ void parse_pool(char *s)
     unsigned long long flush_objs = parse(s,"ot");
 
     parse_string(s,"PT",pool_type,2);
+    pool_type[2] = '\0';
     if (pool_type[1] == 'S')
         return; /* no need to repeat print data for shared pools */
     printf("domid%lu,id%lu[%s]:pgp=%llu(max=%llu) obj=%llu(%llu) "
@@ -286,6 +287,7 @@ void parse_shared_pool(char *s)
     unsigned long long flush_objs = parse(s,"ot");
 
     parse_string(s,"PT",pool_type,2);
+    pool_type[2] = '\0';
     parse_sharers(s,"SC",buf,BUFSIZE);
     printf("poolid=%lu[%s] uuid=%llx.%llx, shared-by:%s: "
            "pgp=%llu(max=%llu) obj=%llu(%llu) "